package com.dujiu.leetcode.slidingWindow.noFixed_lengthSlidingWindow;

import java.util.ArrayList;

public class P3 {
    public int lengthOfLongestSubstring(String s) {
        ArrayList<Character> list = new ArrayList<>();
        int index = 0;
        int max = 0;
        while (index < s.length()){
            // 判断是否包含在list中
            if (!list.contains(s.charAt(index))){
                list.add(s.charAt(index));
                index++;
                max = Math.max(max,list.size());
            }else {
                list.remove(0);
            }
        }
        return max;
    }
}
